﻿<%@ Page Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="Venta.aspx.cs" Inherits="Venta" %>

<asp:Content ID="Content1" ContentPlaceHolderID="Cabecera" runat="Server">
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <div class="form-horizontal" id="contenedor">
        <fieldset>
            <legend>Venta</legend>
            <div class="container">
                <div class="form-group">
                <div class="col-sm-12 alert alert-success pull-right" runat="server" id="alertaExito">
                    <a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
                    <strong>Exito!</strong> Su venta se registró correctamente.
                </div>
            </div>
                <div class="col-md-6">
                    <div class="form-group">
                        <div class="col-sm-3">
                            <label for="txtFecha" class="control-label">Fecha:</label>
                        </div>
                        <div class="col-sm-6">
                            <asp:TextBox ID="txtFecha" runat="server" Text="" CssClass="form-control"></asp:TextBox>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-sm-3 ">
                            <label for="cboTipoFactura" class="control-label">Tipo Factura:</label>
                        </div>
                        <div class="col-sm-6">
                            <asp:DropDownList ID="cboTipoFactura" runat="server" CssClass="form-control"></asp:DropDownList>
                        </div>

                        <div class="form-group">
                            <div class="col-sm-6 col-sm-offset-3 alert alert-warning" runat="server" id="alertaTipoFactura">
                                <a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
                                <strong>Atencion!</strong> El Tipo Factura es Requerido!.
                            </div>
                        </div>
                    </div>
                </div>
                <div class="col-md-6">
                    <div class="form-group">
                        <div class="col-sm-3">
                            <label for="txtNroFactura" class="control-label">Nro de Factura:</label>
                        </div>
                        <div class="col-sm-6">
                            <asp:TextBox ID="txtNroFactura" runat="server" CssClass="form-control"></asp:TextBox>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-sm-3">
                            <label for="cboTipoPago" class="control-label">Tipo Pago:</label>
                        </div>
                        <div class="col-sm-6">
                            <asp:DropDownList ID="cboTipoPago" runat="server" CssClass="form-control"></asp:DropDownList>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-6 col-sm-offset-3 alert alert-warning" runat="server" id="alertaTipoPago">
                                <a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
                                <strong>Atencion!</strong> El Tipo Pago es Requerido!.
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="container">
                <div class="col-md-6 table-responsive">
                    <h5 class="sub-header">Cliente:</h5>
                    <asp:GridView ID="gvClientes"
                        OnSelectedIndexChanged="gvClientes_SelectedIndexChanged"
                        CssClass=" table table-bordered table-condensed"
                        AutoGenerateColumns="False"
                        runat="server"
                        AllowPaging="True"
                        PageSize="5"
                        OnPageIndexChanging="gvClientes_PageIndexChanging">
                        <Columns>
                            <asp:CommandField ShowSelectButton="True" SelectText="Seleccionar" />
                            <asp:BoundField DataField="nombre_tipo_documento" HeaderText="Tipo Documento" />
                            <asp:BoundField DataField="numero_documento" HeaderText="Numero de Documento" />
                            <asp:BoundField DataField="apellido" HeaderText="Apellido" />
                            <asp:BoundField DataField="nombre" HeaderText="Nombre" />
                        </Columns>
                    </asp:GridView>
                    <div class="form-group">
                        <div class="col-sm-3">
                            <label for="txtNroDocumento" class="control-label">Nro Documento:</label>
                        </div>
                        <div class="col-sm-6">
                            <asp:TextBox ID="txtNroDocumento" runat="server" CssClass="form-control"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="rfvCliente" runat="server" ControlToValidate="txtNroDocumento" CssClass="text-danger" ErrorMessage="Seleccione un Cliente de la Grilla." Display="Dynamic" ValidationGroup="B"></asp:RequiredFieldValidator>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-sm-3">
                            <label for="txtApellido" class="control-label">Apellido:</label>
                        </div>
                        <div class="col-sm-6">
                            <asp:TextBox ID="txtApellido" runat="server" Text="" CssClass="form-control"></asp:TextBox>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-sm-3">
                            <label for="txtNombre" class="control-label">Nombre:</label>
                        </div>
                        <div class="col-sm-6">
                            <asp:TextBox ID="txtNombre" runat="server" Text="" CssClass="form-control"></asp:TextBox>
                        </div>
                    </div>
                </div>
                <div class="col-md-6 table-responsive">
                    <h5 class="sub-header">CDs:</h5>
                    <asp:GridView ID="gvCD"
                        OnSelectedIndexChanged="gvCD_SelectedIndexChanged"
                        CssClass=" table table-bordered table-condensed"
                        AutoGenerateColumns="False"
                        runat="server"
                        AllowPaging="True"
                        PageSize="5"
                        OnPageIndexChanging="gvCD_PageIndexChanging">
                        <Columns>
                            <asp:CommandField ShowSelectButton="True" SelectText="Seleccionar" />
                            <asp:BoundField DataField="codigo_cd" HeaderText="Codigo" />
                            <asp:BoundField DataField="titulo" HeaderText="Titulo" />
                            <asp:BoundField DataField="fecha_ultima_reposicion" DataFormatString="{0:d}" HeaderText="Reposicion" />
                            <asp:BoundField DataField="stock" HeaderText="Stock" />
                        </Columns>
                    </asp:GridView>
                    <div class="form-group">
                        <div class="col-sm-3">
                            <label for="txtCodigoCD" class="control-label">Código CD:</label>
                        </div>
                        <div class="col-sm-6">
                            <asp:TextBox ID="txtCodigoCD" runat="server" Text="" CssClass="form-control"></asp:TextBox>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-sm-3">
                            <label for="txtTitulo" class="control-label">Título:</label>
                        </div>
                        <div class="col-sm-6">
                            <asp:TextBox ID="txtTitulo" runat="server" Text="" CssClass="form-control"></asp:TextBox>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-sm-3">
                            <label for="txtPrecio" class="control-label">Precio:</label>
                        </div>
                        <div class="col-sm-6">
                            <asp:TextBox ID="txtPrecio" runat="server" CssClass="form-control"></asp:TextBox>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-sm-3">
                            <label for="txtCantidad" class="control-label">Cantidad:</label>
                        </div>
                        <div class="col-sm-6">
                            <asp:TextBox ID="txtCantidad" runat="server" CssClass="form-control"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="rfvCantidad" runat="server" ControlToValidate="txtCantidad" CssClass="text-danger" ErrorMessage="La cantidad es requerida" Display="Dynamic" ValidationGroup="A"></asp:RequiredFieldValidator>
                            <asp:CompareValidator ID="cvCantidad" runat="server" ControlToValidate="txtCantidad" Operator="DataTypeCheck" Type="Integer" CssClass="text-danger" ErrorMessage="La cantidad debe ser numérica" Display="Dynamic" ValidationGroup="A"></asp:CompareValidator>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-sm-12 alert alert-warning" runat="server" id="alertaStock">
                            <a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
                            <strong>Atencion!</strong> La cantidad ingresasa sobrepasa el stock actual del CD.
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-sm-2 col-sm-offset-5">
                            <asp:Button ID="btnAgregar" runat="server" CssClass="btn btn_sm btn-primary" Text="Agregar" OnClick="btnAgregar_Click" ValidationGroup="A" />
                        </div>
                        <div class="col-sm-3">
                            <asp:Button ID="btnQuitar" runat="server" OnClick="btnQuitar_Click" CssClass="btn btn_sm btn-danger" Text="Quitar" />
                        </div>
                    </div>
                </div>
            </div>
            <div class="container">
                <div class="col-md-10 col-md-offset-1 table-responsive">
                    <h5 class="sub-header">Detalle de Venta:</h5>
                    <asp:GridView ID="gvDetalle"
                        OnSelectedIndexChanged="gvDetalle_SelectedIndexChanged"
                        CssClass=" table table-bordered table-condensed"
                        AutoGenerateColumns="False"
                        runat="server">
                        <Columns>
                            <asp:CommandField ShowSelectButton="True" SelectText="Seleccionar" />
                            <asp:BoundField DataField="codigo_cd" HeaderText="Codigo" />
                            <asp:BoundField DataField="titulo" HeaderText="Titulo" />
                            <asp:BoundField DataField="precio" HeaderText="Precio" />
                            <asp:BoundField DataField="cantidad" HeaderText="Cantidad" />
                            <asp:BoundField DataField="subtotal" HeaderText="Subtotal" />
                        </Columns>
                    </asp:GridView>
                    <div class="form-group">
                        <div class="col-sm-1 col-sm-offset-9">
                            <label for="txtTotal" class="control-label">Total:</label>
                        </div>
                        <div class="col-sm-2">
                            <asp:TextBox ID="txtTotal" runat="server" CssClass="form-control"></asp:TextBox>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-sm-2 col-sm-offset-10">
                            <asp:Button ID="btnConfirmar" runat="server" CssClass="btn btn_sm btn-success" OnClick="btnConfirmar_Click" Text="Confirmar" ValidationGroup="B" />
                        </div>
                    </div>
                </div>
            </div>
        </fieldset>
    </div>
</asp:Content>
